package com.koko.enumeration;

/**
 * 前端游戏排序类型
 */
public enum GamePageQueryType {
    BY_RATING(0, "按评分"),
    BY_SALES(1, "按销量"),
    BY_RELEASE_DATE(2, "按发行日期"),
    BY_DISCOUNT_MODIFIED_TIME(3, "按优惠力度修改时间");

    private final int code;
    private final String description;

    GamePageQueryType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static GamePageQueryType fromCode(int code) {
        for (GamePageQueryType type : GamePageQueryType.values()) {
            if (type.code == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }

    @Override
    public String toString() {
        return this.description;
    }
}
